import request from '../utils/request'

export const insertVoteOfAnswer = (answerId, vote) => {
	return request({
		url: `/answers/${answerId}/voters`,
		method: 'POST',
		data: vote,
	})
}

export const deleteVoteOfAnswer = (answerId, voteId) => {
	return request({
		url: `/answers/${answerId}/voters/${voteId}`,
		method: 'DELETE',
	})
}

export const getUserVoteOfAnswer = (answerId) => {
	return request({
		url: `/answers/${answerId}/voters`,
		method: 'GET',
	})
}

export const updateVoteOfAnswer = (answerId, voteId) => {
	return request({
		url: `/answers/${answerId}/voters/${voteId}`,
		method: 'PATCH',
	})
}

export const insertVoteOfComment = (commentId, vote) => {
	return request({
		url: `/comments/${commentId}/voters`,
		method: 'POST',
		data: vote,
	})
}

export const deleteVoteOfComment = (commentId, voteId) => {
	return request({
		url: `/comments/${commentId}/voters/${voteId}`,
		method: 'DELETE',
	})
}

export const getUserVoteOfComment = (commentId) => {
	return request({
		url: `/comments/${commentId}/voters`,
		method: 'GET',
	})
}

export const updateVoteOfComment = (commentId, voteId, vote) => {
	return request({
		url: `/comments/${commentId}/voters/${voteId}`,
		method: 'PATCH',
		data: vote,
	})
}
